package icu.xuyijie.springbootlearning1.chapter4.schedule;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author 徐一杰
 * @date 2025/03/07 13:40
 * @description 定时任务测试
 */
@Component
public class ScheduleTest {

    //@Async
    @Scheduled(fixedDelay = 1000)
    // 每秒
    //@Scheduled(cron = "*/1 * * * * *")
    // 每年1月20日的1:10:30执行
    //@Scheduled(cron = "30 10 1 20 10 *")
    //@Scheduled(cron = "0 3/1 * * * *")
    //@Scheduled(cron = "0 0 5-15 * * *")
    public void method1() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //System.out.println(Thread.currentThread().getName() + new Date());
    }

}
